home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1996 #1 / Amiga Plus CD - 1996 - No. 1.iso / pd / netz / xbtx_v1.1 / btxservice.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-19  |  5.4 KB  |  170 lines

  1. /*
  2. **    $Id: BTXService.hpp 1.2 1995/08/19 22:34:29 olsen Exp olsen $
  3. **
  4. **    :ts=4
  5. */
  6.  
  7. /*
  8.  * Copyright © 1995 by Olaf Barthel, All Rights Reserved
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Redistributions in binary form must reproduce the above copyright
  16.  *    notice, this list of conditions and the following disclaimer in the
  17.  *    documentation and/or other materials provided with the distribution.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  20.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  22.  * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24.  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  25.  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26.  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  27.  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  28.  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29.  *
  30.  * This software has not been validated by the ``Bundesamt fuer Zulassungen in
  31.  * der Telekommunikation'' of the ``Deutsche Bundepost Telekom'' and thus
  32.  * must not be used for accessing the BTX-Network of the Telekom in Germany.
  33.  *
  34.  * Diese Software hat keine Zulassung durch das Bundesamt fuer Zulassungen in
  35.  * der Telekommunikation der Deutschen Bundespost Telekom und darf daher nicht
  36.  * am Netz der Deutschen Bundespost Telekom in Deutschland betrieben werden.
  37.  */
  38.  
  39. #ifndef _BTXSERVICE_HPP
  40. #define _BTXSERVICE_HPP 1
  41.  
  42. class BTXService;
  43.  
  44. #include "IOChannel.hpp"
  45. #include "BTXDisplay.hpp"
  46. #include "Application.hpp"
  47.  
  48. #include "Font.h"
  49.  
  50. #include <stdio.h>
  51. #include <stdarg.h>
  52.  
  53. enum
  54. {
  55.     MODE_Unknown,
  56.     MODE_3in4,
  57.     MODE_8Bit
  58. };
  59.  
  60. /* information stored at every character location */
  61. struct screen_cell
  62. {
  63.     unsigned short    chr;
  64.     unsigned short    attr;       /* assigned attributes */
  65.     unsigned short    mark;       /* markers for each attribute */
  66.     unsigned short    real;       /* really displayed attributes (size !) */
  67.     unsigned char    set;
  68.     unsigned char    fg;
  69.     unsigned char    bg;
  70. };
  71.  
  72. struct terminal_status
  73. {
  74.     int cursorx, cursory;            /* cursor position (1 based)  */
  75.     int cursor_on;
  76.     int serialmode;                 /* 1=serial, 0=parallel       */
  77.     int wrap;                        /* wraparound ?               */
  78.     int par_attr;                    /* store all attributes       */
  79.     int par_fg, par_bg;
  80.     int G0123L[5];                    /* which set is addressed by G0, ... */
  81.     int leftright[2];                /* actual lower/upper character set  */
  82.     int lastchar;
  83.     int sshift;
  84.     int save_left;                    /* unload L set and invoke previous set  */
  85.     int prim, supp;                 /* where is the prim set (service break) */
  86.     int service_break;                /* (is the protect attr active ?)         */
  87.     int drcs_bits, drcs_step;
  88.     int drcs_w, drcs_h;
  89.     int col_modmap;                 /* modify 1:colormap, 0:DCLUT */
  90.     int clut;                        /* 0 based ! */
  91.     int scroll_upper, scroll_lower;
  92.     int scroll_impl, scroll_area;
  93.     int hold_mosaic;
  94. };
  95.  
  96. class BTXService
  97. {
  98.     public:
  99.  
  100.         BTXService();
  101.         ~BTXService();
  102.  
  103.         LONG Open(BTXDisplay *Disp,Application *Appl);
  104.         VOID Close(VOID);
  105.  
  106.         int ProcessInput(VOID);
  107.  
  108.         UBYTE ConvertChar(int Char,int Set,int Diacritical_Mark);
  109.         VOID GetMatrix(UBYTE *Matrix,int *CursorX,int *CursorY);
  110.  
  111.         int rows, fontheight;                /* 20 rows(12 high) or 24 rows(10 high) */
  112.  
  113.     private:
  114.  
  115.         BTXDisplay     *AppDisplay;
  116.         Application    *App;
  117.  
  118.         struct screen_cell screen[24][40];    /* information for every character */
  119.         int reachedEOF;
  120.         struct terminal_status t,backup;    /* local terminal status */
  121.         int pushback;                        /* can push one byte back into the input stream */
  122.         UBYTE data[4][2*FONT_HEIGHT];        /* local font definition */
  123.         FILE *protocolfile;
  124.  
  125.         FILE *telefile;                        // Telesoftware landet hier
  126.         char telename[256];                    // Name sollte lang genug sein
  127.         long telesize;                        // Länge der Datei
  128.         char teledate[20];                    // Datum, sofern vorhanden
  129.         int telemode;                        // Kodierung, entweder 3-in-4 oder 8-Bit
  130.         int telesequence;                    // Sequenznummer
  131.         BOOL teledownload;                    // True, falls Download erlaubt ist
  132.         unsigned char telebuffer[3000];        // Blockpuffer
  133.  
  134.         void init_layer6(void);
  135.         int process_BTX_data(void);
  136.         inline int layer2getc(void);
  137.         inline void layer2ungetc(int c);
  138.         void default_sets(void);
  139.         void move_cursor(int cmd, int y=0, int x=0);
  140.         int primary_control_C0(int c1);
  141.         void supplementary_control_C1(int c1, int fullrow);
  142.         void do_US(void);
  143.         void do_ESC(void);
  144.         int do_CSI(void);
  145.         void do_DRCS(void);
  146.         void do_DRCS_data(int c);
  147.         void log_DRC(int c, int bits);
  148.         void do_DEFCOLOR(void);
  149.         void do_DEFFORMAT(void);
  150.         void do_RESET(void);
  151.         void do_Telesoftware(void);
  152.         void set_attr(int a, int set, int col, int mode);
  153.         void output(int c);
  154.         void redrawc(int x, int y);
  155.         void updatec(int real, int x, int y);
  156.         void redraw_screen_rect(int x1, int y1, int x2, int y2);
  157.         void update_DRCS_display(int start, int stop, int step);
  158.         void clearscreen(void);
  159.         void scroll(int up);
  160.         void write(const unsigned char *what,int len);
  161.  
  162.         int decode_3in4(const UBYTE *data,UBYTE *out,int total);
  163.  
  164. //        void log(char *fmt,...) { va_list args; va_start(args,fmt); vprintf(fmt,args); va_end(args); };
  165.         void log() {};
  166.         void errlog() {};
  167. };
  168.  
  169. #endif    // _BTXSERVICE_HPP
  170.